<!-- @format -->

<template>
  <section>
    <div
      class="report-list"
      @click="
        identity == 'company'
          ? $router.push(`/reportDetails/${item.id}`)
          : $router.push(`/haveTaskReportDetails/${item.id}`)
      "
      v-for="item in userJobReportList"
      :key="item.id"
    >
      <h3 class="ling-flex">
        <div>
          {{ item.createTime | datefmt('YYYY-MM-DD') }}
          <span>{{ item.userJobStatusDesc }}</span>
        </div>
        <div>
          <span>查看</span>
          <van-icon name="arrow" class="icon" />
        </div>
      </h3>
      <figure>
        <p class="ling-multi-ellipsis-3">{{ item.description }}</p>
        <div
          class="img-box"
          v-for="img in item.reportAnnexList.slice(0, 3)"
          :key="img.id"
          :style="{ backgroundImage: `url(${img.annexUrl})` }"
        ></div>
      </figure>
    </div>
  </section>
</template>

<script>
import { mapState as rootState } from 'vuex'
import { mapActions as rootActions } from 'vuex'
import { getIdentity } from '@/utils/userAuth'
export default {
  name: 'reportListPage',
  data() {
    return {
      identity: getIdentity()
    }
  },
  props: {
    userJobId: {
      required: true
    }
  },
  computed: {
    ...rootState(['userJobReportList'])
  },
  created() {
    this.getUserJobReportList(this.userJobId)
  },
  methods: {
    ...rootActions(['getUserJobReportList'])
  }
}
</script>

<style lang="less" scoped>
.report-list {
  background: white;
  color: #666;
  padding: 5px 20px;
  margin-top: 10px;
  h3 {
    font-size: 12px;
    line-height: 40px;
    font-weight: normal;
    span {
      margin-left: 22px;
      color: #7ac5ef;
    }
    .icon {
      font-size: 10px;
      color: #7ac5ef;
      margin-left: 10px;
      position: relative;
      top: 1px;
    }
  }
  figure {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
    p {
      width: 100%;
      font-size: 14px;
      margin-bottom: 10px;
    }
    .img-box {
      width: 100px;
      height: 75px;
      background: #dbf2ff;
      margin-right: 17px;
      background-size: cover;
    }
    .img-box:last-child {
      margin-right: 0;
    }
  }
}
</style>
